package com.qf.web.controller;

import com.qf.entity.Result;
import com.qf.entity.Student;
import com.qf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stu")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping
    public Result findAll(){

        List<Student> students = studentService.findAll();
        return Result.success(students);
    }

    @GetMapping("/{id}")
    public Result findById(@PathVariable Integer id){
        Student stu = studentService.findById(id);
        return Result.success(stu);
    }
}
